﻿using System;
using System.Collections.Generic;
using Assets.Scripts.GtsScripts;
using UnityEngine;

namespace SaveDataStructures
{
	// Token: 0x02000354 RID: 852
	[Serializable]
	public class EntitiesData
	{
		// Token: 0x06001623 RID: 5667 RVA: 0x0008FDC8 File Offset: 0x0008DFC8
		public EntitiesData(bool save = false)
		{
			if (!save)
			{
				return;
			}
			this.player = new EntityData(GameController.playerInstance);
			this.objects = this.GetObjectList();
			this.giantess = this.GetGiantessList();
		}

		// Token: 0x06001624 RID: 5668 RVA: 0x0008FE00 File Offset: 0x0008E000
		private EntityData[] GetObjectList()
		{
			ObjectManager.Instance.RemoveNullObjectsInList();
			int count = ObjectManager.Instance.objectList.Count;
			EntityData[] array = new EntityData[count];
			int num = 0;
			foreach (KeyValuePair<int, EntityBase> keyValuePair in ObjectManager.Instance.objectList)
			{
				if (keyValuePair.Value == null)
				{
					Debug.LogWarning("Trying to save null object: " + keyValuePair.Key);
				}
				else
				{
					array[num] = new EntityData(keyValuePair.Value);
					num++;
				}
			}
			if (num < count)
			{
				Debug.LogWarning("Null data has been created in object save data caused by null values");
			}
			return array;
		}

		// Token: 0x06001625 RID: 5669 RVA: 0x0008FED4 File Offset: 0x0008E0D4
		private GiantessData[] GetGiantessList()
		{
			int count = ObjectManager.Instance.giantessList.Count;
			GiantessData[] array = new GiantessData[count];
			int num = 0;
			foreach (KeyValuePair<int, Giantess> keyValuePair in ObjectManager.Instance.giantessList)
			{
				if (keyValuePair.Value == null)
				{
					Debug.LogWarning("Trying to save null giantess: " + keyValuePair.Key);
				}
				else
				{
					array[num] = new GiantessData(keyValuePair.Value);
					num++;
				}
			}
			return array;
		}

		// Token: 0x040018D1 RID: 6353
		public EntityData player;

		// Token: 0x040018D2 RID: 6354
		public EntityData[] objects;

		// Token: 0x040018D3 RID: 6355
		public GiantessData[] giantess;
	}
}
